import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Admin
 * Date: 2022-12-08
 * Time: 17:58
 */
public class Demo1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        while(scan.hasNextInt()) {

            int n = scan.nextInt();
            scan.nextLine();
            String str = scan.nextLine();

            Queue<Character> que = new LinkedList<>();
            int result = 0;

            for(int i = 0; i < str.length(); i++) {
                char ch = str.charAt(i);

                if(ch >= '0' && ch <= '9' ) {
                    que.offer(ch);
                }else {
                    if(que.isEmpty()) {
                        ;
                    }else {
                        int num1 = Integer.valueOf(que.poll());
                        int num2 = Integer.valueOf(que.poll());
                        switch(ch) {
                            case '+':
                                result = num1 + num2;
                                break;
                            case '-':
                                result = num1 - num2;
                                break;
                            case '*':
                                result = num1 * num2;
                                break;
                            case '/':
                                result = num1 / num2;
                                break;
                        }
                    }
                }
            }


            System.out.println(result);
        }
    }
}
